<!DOCTYPE html>
<html>
<head>
   <title>CSS Animations - animationiteration event bubbling</title>
   <link rel="author" title="Opera Software ASA" href="http://www.opera.com/">
   <link rel="help" href="http://dev.w3.org/csswg/css3-animations/#animation-events-">
   <meta name="flags" content="dom">
   <meta name="assert" content="The animationiteration event bubbles by
   default">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <style type="text/css">
      @keyframes colorize {
         from {
            background-color: gray;
         }
         to {
            background-color: blue;
         }
      }
      div {
         width: 100px;
         height: 100px;
      }
      .test {
         animation: colorize 200ms 2;
      }
   </style>
   <script type="text/javascript">
      setup({explicit_done:true});
      onload = function() {
         var testName = document.querySelector('title').firstChild.data;
         var divs = document.querySelectorAll('div');
         var log = document.querySelectorAll('p')[0].firstChild;
         var elapsedTime = undefined;
         var passed = undefined;
         var timeout = setTimeout(function() {
            test(function(){assert_true(false);}, testName); done();
            log.data = 'FAIL';
         }, 500);
         divs[0].addEventListener('animationiteration', function(evt) {
            if (passed === undefined) {
               clearTimeout(timeout);
               passed = (elapsedTime != undefined
                         && elapsedTime == evt.elapsedTime);
               test(function(){assert_true(passed);}, testName); done();
               log.data = (passed ? 'PASS' : 'FAIL');
            }
         });
         divs[1].addEventListener('animationiteration', function(evt) {
            if (elapsedTime === undefined) {
               elapsedTime = evt.elapsedTime;
            }
         });
         divs[1].className = 'test';
      };
   </script>
   <style>iframe{display:none}</style>
</head>
<body>
   <p>Testing... (JavaScript required)</p>
   <div>
      <div></div>
   </div>
</body>
</html>
